package com.peanut.baby.mvp.calendar.decorators;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.style.ForegroundColorSpan;

import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.DayViewDecorator;
import com.prolificinteractive.materialcalendarview.DayViewFacade;

import java.util.Collection;
import java.util.HashSet;

/**
 * Created by anonymouslystudio on 2017/7/27.
 */

public class EventDecorator implements DayViewDecorator{
    private Drawable drawable;
    private final HashSet<CalendarDay> dates;
    public EventDecorator(Drawable drawable, Collection<CalendarDay> dates) {
        this.drawable = drawable;
        this.dates = new HashSet<>(dates);
    }

    @Override
    public boolean shouldDecorate(CalendarDay day) {
        return dates.contains(day);
    }

    @Override
    public void decorate(DayViewFacade view) {

        view.setBackgroundDrawable(drawable);
        view.addSpan(new ForegroundColorSpan(Color.WHITE));
    }
}
